﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link href="/ViewV5/CSS/bootstrap3.3.5/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="/ViewV5/CSS/element/index.css">
    <style>
        .el-transfer-panel__list.is-filterable {
            height: 300px;
            padding-top: 0;
        }

        .el-transfer-panel__body {
            height: 352px;
        }
    </style>
</head>
<body>
    <div id="app">
        <el-container>
            <el-main>
                <!--<el-transfer filterable
                             :titles="title"
                             :filter-method="filterMethod"
                             filter-placeholder="请输入字段名称"
                             v-model="value"
                             :data="FiledData">
                </el-transfer>-->
                <p v-text="TDName"></p>
                <el-button type="success" style="margin-top:10px" @click="SaveData()">保存配置</el-button>

                <el-tabs type="border-card" style="margin-top:20PX">

                    <!--<el-tab-pane label="任务设置">
                        <el-form ref="form" :model="form" label-width="80px">
                            <el-form-item label="活动名称">
                                <el-input v-model="form.name"></el-input>
                            </el-form-item>
                            <el-form-item label="活动区域">
                                <el-select v-model="form.region" placeholder="请选择活动区域">
                                    <el-option label="区域一" value="shanghai"></el-option>
                                    <el-option label="区域二" value="beijing"></el-option>
                                </el-select>
                            </el-form-item>

                            <el-form-item label="即时配送">
                                <el-switch v-model="form.delivery"></el-switch>
                            </el-form-item>
                            <el-form-item label="活动性质">
                                <el-checkbox-group v-model="form.type">
                                    <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
                                    <el-checkbox label="地推活动" name="type"></el-checkbox>
                                    <el-checkbox label="线下主题活动" name="type"></el-checkbox>
                                    <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                            <el-form-item label="特殊资源">
                                <el-radio-group v-model="form.resource">
                                    <el-radio label="线上品牌商赞助"></el-radio>
                                    <el-radio label="线下场地免费"></el-radio>
                                </el-radio-group>
                            </el-form-item>

                            <el-form-item>
                                <el-button type="primary" @click="onSubmit">立即创建</el-button>
                                <el-button>取消</el-button>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>-->
                    <el-tab-pane label="字段权限">
                        <el-table :data="FiledData" style="font-size: 12px;width: 100%" stripe border fit>
                            <el-table-column label="字段" width="180" prop="label">
                            </el-table-column>
                            <el-table-column label="隐藏">
                                <template slot-scope="scope">
                                    <el-switch v-model="scope.row.ishide" active-color="#13ce66">
                                    </el-switch>
                                </template>
                            </el-table-column>
                            <el-table-column label="可编辑">
                                <template slot-scope="scope">
                                    <el-switch v-model="scope.row.isedit" active-color="#13ce66">
                                    </el-switch>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-tab-pane>
                    <el-tab-pane label="节点操作" v-if="jdset">
                        <el-form ref="form" :model="form" label-width="180px">
                            <el-form-item label="审批按钮名称">
                                <el-input v-model="form.shname"></el-input>
                            </el-form-item>
                            <el-form-item label="禁止退回">
                                <el-switch v-model="form.nocal"></el-switch>
                            </el-form-item>
                            <el-form-item label="禁止退回到上一步">
                                <el-switch v-model="form.nocalre"></el-switch>
                            </el-form-item>
                            <el-form-item label="启用转单">
                                <el-switch v-model="form.zhuandan"></el-switch>
                            </el-form-item>
                            <el-form-item label="转单角色(转单可选人)" v-show="form.zhuandan">
                                <el-select v-model="form.zdrole" placeholder="请选择转单角色">
                                    <el-option v-for="item in QueryRoles"
                                               :key="item.RoleCode"
                                               :label="item.RoleName"
                                               :value="item.RoleCode">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="自动审核" style="display:none">
                                <el-radio-group v-model="form.zdsh">
                                    <el-radio label="0"></el-radio>
                                    <el-radio label="1"></el-radio>
                                    <el-radio label="2"></el-radio>
                                    <el-radio label="3"></el-radio>

                                </el-radio-group>
                            </el-form-item>
                            <el-form-item label="可用操作" style="display:none">
                                <el-table :data="czData"
                                          border
                                          style="width: 100%" class="mt10">

                                    <el-table-column prop="czname"
                                                     label="操作名称"
                                                     width="140">
                                        <template slot-scope="scope">
                                            <el-input v-model="scope.row.czname" size="mini"></el-input>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="ban"
                                                     label="禁用">
                                        <template slot-scope="scope">
                                            <el-switch v-model="scope.row.ban">
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </el-form-item>


                        </el-form>

                        <!--<el-button type="primary" size="mini" class="mt10 pull-right" @click="addMenu">添加行<i class="el-icon-plus"></i></el-button>-->
                    </el-tab-pane>
                </el-tabs>


            </el-main>
        </el-container>

    </div>
</body>
<script src="/ViewV5/JS/vue.js"></script>
<script type="text/javascript" src="/ViewV5/JS/jquery-1.11.2.min.js"></script>
<script src="/ViewV5/JS/lodash.min.js"></script>
<script src="/ViewV5/JS/element/element.js"></script>
<script src="/ViewV5/JS/bijs.js?v=2"></script>

<script>
    var app = new Vue({
        el: '#app',
        data: function () {
            return {
                pdid: ComFunJS.getQueryString('pdid', '0'),
                tdid: ComFunJS.getQueryString('tdid', '0'),
                FiledData: [],
                title: ["全部字段", "可编辑字段"],
                value: [],
                QueryRoles:[],
                TDName: "",
                jdset: false,
                form: {
                    shname: "审核",
                    nocal: false,
                    nocalre: false,
                    zhuandan: false,
                    zdrole:""
                },
                czData: [{ czname: "审核", ban: false }, { czname: "退回", ban: false }],
                filterMethod(query, item) {
                    return item.label.indexOf(query) > -1;
                }
            }
        },
        methods: {
            InitForm: function () {
                $.getJSON("/api/Bll/ExeAction?Action=FORMBI_GETFORMFILED", { P1: app.pdid, P2: app.tdid }, function (result) {
                    if (!result.ErrorMsg) {
                        _.forEach(result.Result, function (item) {
                            var isedit = result.Result1.indexOf(item.TableFiledColumn) > -1;
                            var ishide = result.Result2.indexOf(item.TableFiledColumn) > -1;;
                            app.FiledData.push({ label: item.TableFiledName, key: item.TableFiledColumn, ishide: ishide, isedit: isedit })
                        })
                        if (result.Result1) {
                            app.value = result.Result1.split(',');
                        }
                        if (result.Result3) {
                            app.TDName = result.Result3.TaskName + '-' + result.Result3.TaskAssInfo;
                            app.jdset = result.Result3.NodeType != "START";
                            if (result.Result3.isCanEdit) {
                                app.form = JSON.parse(result.Result3.isCanEdit);
                            }

                        }
                    }
                });
                $.getJSON('/api/Auth/ExeAction?Action=GETROLE', {}, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        app.QueryRoles = resultData.Result;
                    }
                })
            },

            SaveData: function () {
                var editfid = [];
                var hidfid = [];
                _.forEach(app.FiledData, function (item) {
                    if (item.ishide) {
                        hidfid.push(item.key);
                    }
                    if (item.isedit) {
                        editfid.push(item.key);
                    }
                })

                $.getJSON("/api/Bll/ExeAction?Action=FORMBI_SETPDFILED", { P1: app.tdid, P2: editfid.join(','), hidfid: hidfid.join(','), form: JSON.stringify(app.form) }, function (result) {
                    if (!result.ErrorMsg) {
                        app.$notify({
                            title: '成功',
                            message: '操作成功',
                            type: 'success'
                        });
                    }
                });
            }
        },
        mounted: function () {
            var pro = this;
            pro.$nextTick(function () {
                pro.InitForm();
            })
        }
    })
</script>
</html>